import os
import stat

file_list = ["1.c", "dir", "link", "/dev/zero", "/dev/ram0"]
for file in file_list:
    # mode=os.stat(file).st_mode
    mode = os.lstat(file).st_mode
    if stat.S_ISDIR(mode):
        print(f"dir {file}")
    elif stat.S_ISREG(mode):
        print(f"reg {file}")
    elif stat.S_ISLNK(mode):
        print(f"link {file}")
    elif stat.S_ISCHR(mode):
        print(f"chr {file}")
    elif stat.S_ISBLK(mode):
        print(f"blk {file}")
    else:
        print(f"unknown mode")

""" 测试1: os.stat(file).st_mode
reg 1.c
dir dir
dir link
chr /dev/zero
blk /dev/ram0

"""

""" 测试2: os.lstat(file).st_mode
reg 1.c
dir dir
link link
chr /dev/zero
blk /dev/ram0

"""
